package phase6;

import cs340.stormtroopers.hypeerweb.HyPeerWeb;
import cs340.stormtroopers.hypeerweb.Node;

public class PersistenceTest
{

	/**
	 * @param args
	 */
	public static void main(String[] args)
	{
		HyPeerWeb hw = HyPeerWeb.getSingleton();
		hw.setNodesShouldSerializeToProxies(false);
		ObjectDB db = ObjectDB.getSingleton();
		db.store(HyPeerWeb.SINGLETON_OBJECT_ID, hw);
		Node n0 = new Node(42);
		Node n1 = new Node(42);
		Node n2 = new Node(42);
		hw.addToHyPeerWeb(n0, null);
		hw.addToHyPeerWeb(n1, null);
		hw.addToHyPeerWeb(n2, null);
		assert(n0.getWebIdValue() == 0);
		assert(n1.getWebIdValue() == 1);
		assert(n2.getWebIdValue() == 2);
		System.out.println("Finished creating nodes and adding to hyperweb. Dumping objectDB:");
		db.dump();
		System.out.println("Dumping DB to disk...");
		String filename = System.getProperty("user.home") + "/CS340HyPeerWebData/persistenceTest.dump";
		db.save(filename);
		System.out.println("Done.");
	}

}
